﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArgsHandler
{
    /// <summary>
    /// The Argument class represents a singular argument within the collection inputted in the command line.
    /// </summary>
    public class Argument
    {
        private string prefix;
        public string Prefix {
            get {
                if (string.IsNullOrEmpty(prefix))
                    return "N/A";
                return prefix;
            }

        }

        // Data property
        private string data;
        public string Data {
            get {
                if (string.IsNullOrEmpty(data))
                    return "N/A";
                return data;
            }
        }

        // DataExists property
        private bool dataExists;
        public bool DataExists { get { return dataExists; } }

        /// <summary>
        /// Constructor for the argument class.
        /// Example taken: -ip 127.0.0.1
        /// </summary>
        /// <param name="Prefix">
        /// Represents the prefix of the argument.
        /// Within the constructor example, the prefix is the string 'ip'.
        /// </param>
        /// <param name="Data">
        /// Represents the data of the argument.
        /// Within the constructor example, the data is the string '127.0.0.1'.
        /// </param>
        public Argument(string Prefix, string Data)
        {
            // Assignment
            prefix = Prefix;
            data = Data;

            // Data checking
            if (data == null || string.IsNullOrWhiteSpace(data))
                dataExists = false;
            else
                dataExists = true;
        }

        /// <summary>
        /// The string value of the argument.
        /// </summary>
        /// <returns>Returns the prefix and the data separated by a tab.</returns>
        public override string ToString()
        {
            return string.Format("{0}\t{1}", Prefix, Data);
        }
    }

}
